package com.ruoyi.web.controller.wnjk.physical;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.wnjk.domain.po.PhysicalReport;
import com.ruoyi.system.wnjk.service.IWnjkPhysicalExaminationReportService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 体检报告Controller
 * 
 * @author ruoyi
 * @date 2025-03-06
 */
@RestController
@RequestMapping("/Physical/report")
public class ReportController extends BaseController
{
    @Autowired
    private IWnjkPhysicalExaminationReportService wnjkPhysicalExaminationReportService;

    /**
     * 查询体检报告列表
     */
    @PreAuthorize("@ss.hasPermi('Physical:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(PhysicalReport wnjkPhysicalExaminationReport)
    {
        startPage();
        List<PhysicalReport> list = wnjkPhysicalExaminationReportService.selectWnjkPhysicalExaminationReportList(wnjkPhysicalExaminationReport);
        return getDataTable(list);
    }

    /**
     * 导出体检报告列表
     */
    @PreAuthorize("@ss.hasPermi('Physical:report:export')")
    @Log(title = "体检报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PhysicalReport wnjkPhysicalExaminationReport)
    {
        List<PhysicalReport> list = wnjkPhysicalExaminationReportService.selectWnjkPhysicalExaminationReportList(wnjkPhysicalExaminationReport);
        ExcelUtil<PhysicalReport> util = new ExcelUtil<PhysicalReport>(PhysicalReport.class);
        util.exportExcel(response, list, "体检报告数据");
    }

    /**
     * 获取体检报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('Physical:report:query')")
    @GetMapping(value = "/{reportId}")
    public AjaxResult getInfo(@PathVariable("reportId") Long reportId)
    {
        return success(wnjkPhysicalExaminationReportService.selectWnjkPhysicalExaminationReportByReportId(reportId));
    }

    /**
     * 新增体检报告
     */
    @PreAuthorize("@ss.hasPermi('Physical:report:add')")
    @Log(title = "体检报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PhysicalReport wnjkPhysicalExaminationReport)
    {
        return toAjax(wnjkPhysicalExaminationReportService.insertWnjkPhysicalExaminationReport(wnjkPhysicalExaminationReport));
    }

    /**
     * 修改体检报告
     */
    @PreAuthorize("@ss.hasPermi('Physical:report:edit')")
    @Log(title = "体检报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PhysicalReport wnjkPhysicalExaminationReport)
    {
        return toAjax(wnjkPhysicalExaminationReportService.updateWnjkPhysicalExaminationReport(wnjkPhysicalExaminationReport));
    }

    /**
     * 删除体检报告
     */
    @PreAuthorize("@ss.hasPermi('Physical:report:remove')")
    @Log(title = "体检报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportIds}")
    public AjaxResult remove(@PathVariable Long[] reportIds)
    {
        return toAjax(wnjkPhysicalExaminationReportService.deleteWnjkPhysicalExaminationReportByReportIds(reportIds));
    }
}
